﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Rubik.Common.Operations;

namespace Rubik.Common
{
    public class CubeGenerator
    {
        private const int MoveCount = 30;

        private static readonly IList<ICubeOperation> operations =
            new List<ICubeOperation>();

        private static readonly Random random = new Random(
            (int)(DateTime.Now.Ticks & 0xFFFFFFFF));

        static CubeGenerator()
        {
            operations.Add(new FrontRotateClockwise(0));
            operations.Add(new FrontRotateClockwise(1));
            operations.Add(new FrontRotateClockwise(2));

            operations.Add(new LeftRotateClockwise(0));
            operations.Add(new LeftRotateClockwise(1));
            operations.Add(new LeftRotateClockwise(2));

            operations.Add(new TopRotateClockwise(0));
            operations.Add(new TopRotateClockwise(1));
            operations.Add(new TopRotateClockwise(2));
        }

        public static void Generate(Cube cube)
        {
            for (int i = 0; i < MoveCount; i++)
            {
                int operationIndex = random.Next(0, operations.Count);
                operations[operationIndex].Do(cube);
            }
        }
    }
}
